const{
  renderAdmin,
  addAdmin,
  deleteAdmin,
  oneAdmin,
  updateAdmin,
  getMerchantList,
  freezeMerchant,
  unFreezeMerchant,
  getShopList,
  handleSuccess,
  handleFail
}=require('../dao/adminDao');

//渲染管理员列表
module.exports.renderAdmin = async () => {
  return await renderAdmin();
}

//新增管理员
module.exports.addAdmin = async (admin) => {
  let data = await addAdmin(admin);
  if(data._id) {
    return true
  }
  return false
}

//删除管理员
module.exports.deleteAdmin = async (params) => {
  let data = await deleteAdmin(params);
  if(data.deletedCount === 1) {
    return true
  }
  return false
}

//通过_id来获取一个管理员的数据
module.exports.oneAdmin = async (params) => {
  return await oneAdmin(params)
}

//修改管理员
module.exports.updateAdmin = async (params) => {
  return await updateAdmin(params)
}

//渲染商人列表
module.exports.getMerchantList = async () => {
  return await getMerchantList();
}

//冻结商人
module.exports.freezeMerchant = async (params) => {
  let data = await freezeMerchant(params);
  return data;
}

//解冻商人
module.exports.unFreezeMerchant = async (_id) => {
  let data = await unFreezeMerchant(_id);
  return data;
}

//门店列表
module.exports.getShopList = async () => {
  let data = await getShopList();
  if(data.length) {
    return data;
  }
}

//门店通过审核
module.exports.handleSuccess = async (params) => {
  let data = await handleSuccess(params);
  return data;
}

//门店审核失败
module.exports.handleFail = async (params) => {
  let data = await handleFail(params);
  return data;
}
